package com.apitest.utils;

import com.apitest.moudle.Base;
import org.beetl.core.Configuration;
import org.beetl.core.GroupTemplate;
import org.beetl.core.Template;
import org.beetl.core.resource.FileResourceLoader;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @program: APITest
 * @description:
 * @author: shixing
 * @create: 2021-06-29 16:43
 **/
public class TemplateUtils {

    public static String parseTestCodeTemplate(Base base) throws IOException {
        String root = FsKit.getTargetPath("classes");
        FileResourceLoader resourceLoader = new FileResourceLoader(root, "utf-8");
        Configuration cfg = Configuration.defaultConfiguration();
        GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
        Template t = gt.getTemplate("template.btl");
        t.binding("base",base);
        return t.render();
    }
}
